package com.uqbar.game;

import java.awt.Color;
import java.util.List;

import com.uqbar.game.asteroid.tipe.Asteroid;
import com.uqbar.game.random.RandomAsteroid;
import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.appearances.Circle;
import com.uqbar.vainilla.colissions.CollisionDetector;
import com.uqbar.vainilla.sound.Sound;
import com.uqbar.vainilla.sound.SoundBuilder;

public class Bullet extends AsteroidComponent{
	private double speed = 50;
	private int diameter = 5;
	private Color color = Color.WHITE;
	private double movX, movY;
	private double t1 = 0;
	private double t2 = 0;
//	private List<Asteroid> asteroids;
	private Sound soundExploitAsteroid= new SoundBuilder().buildSound("/sound/explosion/ex1.WAV");
	private Spacecraft spacecraft;

	private RandomAsteroid randomAsteroid;
	
	public Bullet(double d, double e, double movX, double movY, List<Asteroid> asteroids, Spacecraft spacecraft, RandomAsteroid randomAsteroid) {
		super(d, e);
		this.movX = movX;
		this.movY = movY;
//		this.asteroids = asteroids;
		this.spacecraft = spacecraft;
		this.randomAsteroid = randomAsteroid;
		this.setAppearance(new Circle(this.color, this.diameter));
	}
	
	public void update(DeltaState deltaState) {
		super.update(deltaState);
		
		double movX = deltaState.getDelta() * this.speed * this.movX;
		double movY = deltaState.getDelta() * this.speed * this.movY;
		
		this.move(movX, movY);	
		this.align(diameter);
		this.randomAsteroid.collisionWith(this);
		
		//que la bala desaparezca
		if(t1+15 == t2){
			this.destroy();
		}
		t2++;
		
	}

	
	public Spacecraft getSpacecraft() {
		return spacecraft;
	}

	public void setSpacecraft(Spacecraft spacecraft) {
		this.spacecraft = spacecraft;
	}

	public double getMovX() {
		return movX;
	}

	public void setMovX(double movX) {
		this.movX = movX;
	}

	public double getMovY() {
		return movY;
	}

	public void setMovY(double movY) {
		this.movY = movY;
	}

	public void setSpeed(double speed) {
		this.speed = speed;
	}

	public double getSpeed() {
		return speed;
	}
	public int getDiameter() {
		return diameter;
	}

	public void setDiameter(int diameter) {
		this.diameter = diameter;
	}

	public void setSoundExploitAsteroid(Sound soundExploitAsteroid) {
		this.soundExploitAsteroid = soundExploitAsteroid;
	}

	public Sound getSoundExploitAsteroid() {
		return soundExploitAsteroid;
	}


}
